from utils.ConfigUtils import read_config
import pymysql
import pandas as pd

def doris_getData(sql):

    # Doris数据库连接参数
    dorisConfig = read_config("config/jdbc.properties")
    doris_host = dorisConfig.get("doris_host")
    doris_port = int(dorisConfig.get("doris_port"))  # 注意：这里应该是整数
    doris_user = dorisConfig.get("doris_user")
    doris_password = dorisConfig.get("doris_password")
    doris_db = dorisConfig.get("doris_db")
    # 建立连接
    conn = pymysql.connect(host=doris_host,
                           port=doris_port,
                           user=doris_user,
                           passwd=doris_password,
                           db=doris_db)
    # 编写您的SQL查询
    query = sql
    # 使用pandas的read_sql_query方法执行查询并转换为DataFrame
    df = pd.read_sql_query(query, conn)
    # 打印DataFrame
    print(df)
    # 关闭连接
    conn.close()